package org.spark.api.config;

import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.util.Bytes;
/**
 * @author chenwy
 */
public enum HBaseTable {


    /**
     * 礼物收入榜
     */
    LIVE_AUTHOR_GIFT;

    HBaseTable() {
        this.namespace = "dy".getBytes();
        this.qualifier = this.name().toLowerCase().replaceAll("_", "-").getBytes();
    }

    HBaseTable(String namespace) {
        this.namespace = namespace.getBytes();
        this.qualifier = this.name().toLowerCase().replaceAll("_", "-").getBytes();
    }

    public static byte[] NAMESPACE = "dy".getBytes();


    private final byte[] qualifier;

    private final byte[] namespace;

    HBaseTable(String namespace, String qualifier) {
        this.namespace = namespace.getBytes();
        this.qualifier = qualifier.getBytes();
    }

    public TableName getTableName() {
        return TableName.valueOf(namespace, qualifier);
    }


    public TableName getTableName(String... strings) {
        String suffix = String.join("-", strings);
        String tableName = Bytes.toString(qualifier) + "-" + suffix;
        return TableName.valueOf(namespace, tableName.getBytes());
    }

}
